package cn.zhaozhiqi.autoconfiguration;

import cn.zhaozhiqi.template.AliPayTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.factory.Factory.Payment;
import com.alipay.easysdk.kernel.Config;
import com.alipay.easysdk.kernel.util.ResponseChecker;
import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;




@Configuration
public class PayAutoConfiguration {

    @Bean
    public AliPayTemplate getAliPayTemplate(){
        // 1. 设置参数（全局只需设置一次）,所以在创造对象的时候一起进行加载
        Factory.setOptions(getOptions());
        return new AliPayTemplate();
    }

    private static Config getOptions() {
        Config config = new Config();
        config.protocol = "https";
        config.gatewayHost = "openapi-sandbox.dl.alipaydev.com";
        config.signType = "RSA2";
        config.appId = "9021000143643518";
        // 为避免私钥随源码泄露，推荐从文件中读取私钥字符串而不是写入源码中
        config.merchantPrivateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAdV+8teGPYVJ0SiTqWPuhpvYyvkgMxKHteDFsNzcSQ5apxsMtdVrLKFE6vuoPR7MKeZHOqB6anxDCxshzfDCdhdoeH803NablQKLmamEs1J0I3/jU4ewmJrhysQTjM2Qi0HE+SyIhkdwO8So+sIZ15VIBnucKF2kGBFQquirzZiBvCuydoO/vxSjoqqGM2ldx+Vrn+P30+yX+ZfdSujF8n8Bf6+rfA74t5aRh0uk/+jTWDQ47jMyWl2sM1LvflquEEg6QeduzbIUfcFpQG9lpFK51Tw03nBLgTS3NVTU5kA1StlQzaz47djT7C6WOGNXOrc2ZAiLwOjPDc/+WTYP3AgMBAAECggEBAKioM3XUjg5wYym1sBQOVrWa8zYUul82EhFguy7yVDiVMnsly/USWraeZlDs7YDmfGg5kSVg/zDRJIcMXK2Xr6LbogG0LMqtIczVj+wMXYxD5jnYzN8B/UiRtiIMLxRL/PzlXdgRT5/LiuUtQrAdUjgO9oalEiMt0MONF5U6AFm7KLV1qSYlgy7vOvsEECqFRddcxhdwn3Rs6441ISdXJxKUv/9p9Fez1gw0QC5aguvixeY7d17WX5X41BhyOsSzeV96GY0AROss90w1EXe7RNLiy4sgVS8rmFdoJGiGAzeSgREoaN1HWLY8W5lh07eCBqoEhNuTwqyEIOED/1egJMECgYEA31LpGsGkIk9MB82186gOMpL6NS9RSDTq0WAETLJBbNbhHymZEpWvy+hAukphbx5FowuF+UkuQefiA7kGdBFVqQd+MPK3nFQyNNDiq6Qh3+VpkcUhpajuTtZgcSy1H2xq50rt1/sLB0oFfcLv5/RM8il3VcPo1ojtv/sL2XQ5pzUCgYEA3J5VGrsCJW/AXlvA4yzpmOL6mCJR9CHJgr+Ktqjr9KMyHpu7D59oyBYry4UMe8d2FgMmIlgv+jTJZkB8WyxwTYlvasLD6jy8kSqW0k9Y85FBo1kUVZ9vb16dMvFiKdpQSzT+LfUxOWoW89CZob6kkJyj6YzirQEISGXbk85Hp/sCgYEAxfmIMHINgWTur9RLQs9ulqL5MIDb+7j9mdMWvK8hlM0BEVEdI/6Ss58XEo6xxYH+lcW3ZQDdAwv/rvEtqWNcntXHprjk0K9LOssaxrJgXU3QwqsRYvxZFoaxRGMvxcWlF5mzM86XPkT+jThs2SIXvG3KHrvoA5ervI9fN8zy9ykCgYEAhsmVZUdsAENOXFfieOkvruC+CcSuHWGnI+KydPavcj9il6C9oMXb1qL1Dtqyzc0HMFusKL+IUG1/vqEXWPzFgBm/oJJt7+Y7rtU+YC9qQSU13P7HlahbBMfhcwZW2wsuk0RFJv7unA1dCIkh09gN4uxQmJgixWAkF1dj1+HnlZECgYBiTRqm2f7zqgF4egdAvUjcTBJfN3Vvm1wY/GroUiir87G8oC0UT/PU92lIr6egsIwkraoUz1RpPiX0Hc2WZET46FjhG507cBOyLwyD4r8t+lQwq7qDiCx8opluCsY0gCgh8lQgFuNVR6dQG9uTO6Yw5QQRIX3EM/BjSPieqrDBqQ==";
        //可设置异步通知接收服务地址（可选），支付完成后会选择跳转到这个界面，需要用内网穿透
        config.notifyUrl = "";

        return config;
    }

}
